package dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * A data access object (DAO) providing persistence and search support for
 * Others1 entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see dao.Others1
 * @author MyEclipse Persistence Tools
 */

public class Others1DAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(Others1DAO.class);
	// property constants
	public static final String YUNJIABASEPRICELIMIT = "yunjiabasepricelimit";
	public static final String YUNJIAYOUHUI1 = "yunjiayouhui1";
	public static final String ORDERYOUHUI2 = "orderyouhui2";
	public static final String HOTSPOTSID = "hotspotsid";
	public static final String HOTSPOTEID = "hotspoteid";
	public static final String ADMINEMAIL = "adminemail";

	protected void initDao() {
		// do nothing
	}

	public void save(Others1 transientInstance) {
		log.debug("saving Others1 instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(Others1 persistentInstance) {
		log.debug("deleting Others1 instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Others1 findById(java.lang.Integer id) {
		log.debug("getting Others1 instance with id: " + id);
		try {
			Others1 instance = (Others1) getHibernateTemplate().get(
					"dao.Others1", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Others1 instance) {
		log.debug("finding Others1 instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Others1 instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Others1 as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByYunjiabasepricelimit(Object yunjiabasepricelimit) {
		return findByProperty(YUNJIABASEPRICELIMIT, yunjiabasepricelimit);
	}

	public List findByYunjiayouhui1(Object yunjiayouhui1) {
		return findByProperty(YUNJIAYOUHUI1, yunjiayouhui1);
	}

	public List findByOrderyouhui2(Object orderyouhui2) {
		return findByProperty(ORDERYOUHUI2, orderyouhui2);
	}

	public List findByHotspotsid(Object hotspotsid) {
		return findByProperty(HOTSPOTSID, hotspotsid);
	}

	public List findByHotspoteid(Object hotspoteid) {
		return findByProperty(HOTSPOTEID, hotspoteid);
	}

	public List findByAdminemail(Object adminemail) {
		return findByProperty(ADMINEMAIL, adminemail);
	}

	public List findAll() {
		log.debug("finding all Others1 instances");
		try {
			String queryString = "from Others1";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Others1 merge(Others1 detachedInstance) {
		log.debug("merging Others1 instance");
		try {
			Others1 result = (Others1) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Others1 instance) {
		log.debug("attaching dirty Others1 instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Others1 instance) {
		log.debug("attaching clean Others1 instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static Others1DAO getFromApplicationContext(ApplicationContext ctx) {
		return (Others1DAO) ctx.getBean("Others1DAO");
	}
}